package syn;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author zfj
 * @date 2021/10/17 -13:03
 * JUC安全
 */
public class TestJUC {
	public static void main(String[] args) {
		CopyOnWriteArrayList<String> list=new CopyOnWriteArrayList<String>();
		for (int i = 0; i < 10000; i++) {
			new Thread(()->{
				list.add(Thread.currentThread().getName());
			}).start();
		}
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(list.size());
	}
}
